import $ from "jquery";
import Swipe from "./swipe";
var mySwipeImg = {
    _init: function () {
        mySwipeImg.dotNumber();
        mySwipeImg.mySwipe();
    },
    dotNumber: function () {
        var imgLength = $('.circle_img').length;
        if (imgLength > 1) {
            var position = $("#position");
            for (var i = 0; i < imgLength; i++) {
                var li = $("<li/>").appendTo(position);
            }
            var circleWidth = position.width();
            position.css("margin-left", -circleWidth / 2 + "px");
            mySwipeImg.dots = position.find('li');
            mySwipeImg.dots.eq(0).addClass('on');
        }
    },
    mySwipe: function () {
        Swipe(document.getElementById('mySwipe'), {
            startSlide: 0,
            auto: 3000,
            continuous: true,
            disableScroll: true,
            stopPropagation: true,
            callback: function (pos) {
                var i = mySwipeImg.dots.length;
                while (i--) {
                    mySwipeImg.dots.attr('class', '');
                }
                mySwipeImg.dots.eq(pos).attr('class', 'on');
            },
            transitionEnd: function (index, element) { }
        });
    }
};

export default mySwipeImg;